{{ 'section-main-product.css' | asset_url | stylesheet_tag }}
<div class="page-width">
  <div class="ksp-header">
    {% if section.settings.heading != blank %}
    <h2 class="left">{{ section.settings.heading  }}</h2>
    {% endif %}
    {% if section.settings.richtext != blank %}
     <div class="left">{{ section.settings.richtext }}</div>
    {% endif %}
  </div>
  <div class="tab-block_text">
    <tab-toggle class="tab-block"> 
        <div class="ksp-tab">
          {%- for block in section.blocks -%}
              {% case block.type %}                                                         
                  {%- when 'tab' -%}
                  <div class="tab {% if forloop.index0 == 0 %} cur {% endif %}" {{ block.shopify_attributes }}>
                        {% if block.settings.text != blank %}                       
                            {{ block.settings.text }}                    
                        {% endif %}
                      </div>
              {%- endcase -%}
          {%- endfor -%}            
        </div>
       <div class="tab-image">
        <div class="image-with-text__media image-with-text__media--{{ section.settings.height }} {% if section.settings.image != blank %}media{% else %}image-with-text__media--placeholder placeholder{% endif %}"
          {% if section.settings.height == 'adapt' and section.settings.image != blank %} style="padding-bottom: {{ 1 | divided_by: section.settings.image.aspect_ratio | times: 100 }}%;"{% endif %}
          >
          {%- if section.settings.image != blank -%}
            <img
              srcset="{%- if section.settings.image.width >= 165 -%}{{ section.settings.image | img_url: '165x' }} 165w,{%- endif -%}
                {%- if section.settings.image.width >= 323 -%}{{ section.settings.image | img_url: '323x' }} 323w,{%- endif -%}
                {%- if section.settings.image.width >= 360 -%}{{ section.settings.image | img_url: '360x' }} 360w,{%- endif -%}
                {%- if section.settings.image.width >= 535 -%}{{ section.settings.image | img_url: '535x' }} 535w,{%- endif -%}
                {%- if section.settings.image.width >= 750 -%}{{ section.settings.image | img_url: '750x' }} 750w,{%- endif -%}
                {%- if section.settings.image.width >= 1070 -%}{{ section.settings.image | img_url: '1070x' }} 1070w,{%- endif -%}
                {%- if section.settings.image.width >= 1500 -%}{{ section.settings.image | img_url: '1500x' }} 1500w,{%- endif -%}
                {{ section.settings.image | img_url: 'master' }} {{ section.settings.image.width }}w"
                data-src="{{ section.settings.image | img_url: '1500x' }}"
              sizes="(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 2 }}px, (min-width: 750px) calc((100vw - 130px) / 2), calc((100vw - 50px) / 2)"
              alt="{{ section.settings.image.alt | escape }}"
              loading="lazy"
              class="lazyload"
              width="{{ section.settings.image.width }}"
              height="{{ section.settings.image.height }}"
            >
          {%- else -%}
            {{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
          {%- endif -%}
        </div>
       </div>
        <div class="point-feature">
          {%- for block in section.blocks -%}
            {% case block.type %}                                                         
                {%- when 'point' -%}
                    <div class="content points_{{ forloop.index0 }} {% if forloop.index0 == 3 %} cur {% endif %}" {{ block.shopify_attributes }}>
                      {% if block.settings.text_1 != blank %}
                            <div class="text text_1">                              
                              <modal-opener class="twy-button product-popup-modal__opener no-js-hidden" data-modal="#PopupModal-{{ block.id }}-text_1" >
                                <button id="ProductPopup-{{ block.id }}-text_1" class="product-popup-modal__button link" type="button" aria-haspopup="dialog">
                                  <span class="text-h1">{{ block.settings.text_1 }}</span> {% render 'icon-jia' %}
                                </button>
                              </modal-opener>
                              <modal-dialog id="PopupModal-{{ block.id }}-text_1" class="product-popup-modal">
                                <div role="dialog" aria-label="{{  block.settings.text_1 }}" aria-modal="true" class="product-popup-modal__content" >
                                   <div class="modal-popop">
                                      <div class="image-with-text__media image-with-text__media--{{ block.settings.height }} {% if block.settings.image != blank %}media{% else %}image-with-text__media--placeholder placeholder{% endif %}"
                                    {% if block.settings.image != blank %} style="padding-bottom: {{ 1 | divided_by: block.settings.image.aspect_ratio | times: 100 }}%;" {% endif %}>
                                    {%- if block.settings.image != blank -%}
                                      <img
                                        srcset="{%- if block.settings.image.width >= 165 -%}{{ block.settings.image | img_url: '165x' }} 165w,{%- endif -%}
                                          {%- if block.settings.image.width >= 323 -%}{{ block.settings.image | img_url: '323x' }} 323w,{%- endif -%}
                                          {%- if block.settings.image.width >= 360 -%}{{ block.settings.image | img_url: '360x' }} 360w,{%- endif -%}
                                          {%- if block.settings.image.width >= 535 -%}{{ block.settings.image | img_url: '535x' }} 535w,{%- endif -%}
                                          {%- if block.settings.image.width >= 750 -%}{{ block.settings.image | img_url: '750x' }} 750w,{%- endif -%}
                                          {%- if block.settings.image.width >= 1070 -%}{{ block.settings.image | img_url: '1070x' }} 1070w,{%- endif -%}
                                          {%- if block.settings.image.width >= 1500 -%}{{ block.settings.image | img_url: '1500x' }} 1500w,{%- endif -%}
                                          {{ block.settings.image | img_url: 'master' }} {{ block.settings.image.width }}w"
                                        data-src="{{ block.settings.image | img_url: '1500x' }}"
                                        sizes="(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 2 }}px, (min-width: 750px) calc((100vw - 130px) / 2), calc((100vw - 50px) / 2)"
                                        alt="{{ block.settings.image.alt | escape }}"
                                        loading="lazy"
                                        class="lazyload"
                                        width="{{ block.settings.image.width }}"
                                        height="{{ block.settings.image.height }}"
                                      >
                                    {%- else -%}
                                      {{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
                                    {%- endif -%}
                                    </div>
                                      <div class="pop_content">
                                        <div class="pop_text">{{ block.settings.text_1 }}</div>
                                        <div>{{ block.settings.richtext }}</div>
                                      </div>
                                  </div>
                                  <button id="ModalClose-{{ block.id }}-text_1" type="button" class="product-popup-modal__toggle" aria-label="{{ 'accessibility.close' | t }}">{% render 'pop-close' %}</button>
                                </div>
                             </modal-dialog>                       
                         </div>
                      {% endif %}
                      {% if block.settings.text_2 != blank %}
                          <div class="text text_2"> 
                            <modal-opener class="twy-button product-popup-modal__opener no-js-hidden" data-modal="#PopupModal-{{ block.id }}-text_2" >
                              <button id="ProductPopup-{{ block.id }}-text_2" class="product-popup-modal__button link" type="button" aria-haspopup="dialog">
                                <span class="text-h1">{{ block.settings.text_2 }}</span> {% render 'icon-jia' %}
                              </button>
                            </modal-opener>
                            <modal-dialog id="PopupModal-{{ block.id }}-text_2" class="product-popup-modal">
                              <div role="dialog" aria-label="{{  block.settings.text_2 }}" aria-modal="true" class="product-popup-modal__content" >
                                <div class="modal-popop">
                                  <div class="image-with-text__media image-with-text__media--{{ block.settings.height }} {% if block.settings.image_2 != blank %}media{% else %}image-with-text__media--placeholder placeholder{% endif %}"
                                    {% if block.settings.image_2 != blank %} style="padding-bottom: {{ 1 | divided_by: block.settings.image_2.aspect_ratio | times: 100 }}%;" {% endif %}>
                                    {%- if block.settings.image_2 != blank -%}
                                      <img
                                        srcset="{%- if block.settings.image_2.width >= 165 -%}{{ block.settings.image_2 | img_url: '165x' }} 165w,{%- endif -%}
                                          {%- if block.settings.image_2.width >= 323 -%}{{ block.settings.image_2 | img_url: '323x' }} 323w,{%- endif -%}
                                          {%- if block.settings.image_2.width >= 360 -%}{{ block.settings.image_2 | img_url: '360x' }} 360w,{%- endif -%}
                                          {%- if block.settings.image_2.width >= 535 -%}{{ block.settings.image_2 | img_url: '535x' }} 535w,{%- endif -%}
                                          {%- if block.settings.image_2.width >= 750 -%}{{ block.settings.image_2 | img_url: '750x' }} 750w,{%- endif -%}
                                          {%- if block.settings.image_2.width >= 1070 -%}{{ block.settings.image_2 | img_url: '1070x' }} 1070w,{%- endif -%}
                                          {%- if block.settings.image_2.width >= 1500 -%}{{ block.settings.image_2 | img_url: '1500x' }} 1500w,{%- endif -%}
                                          {{ block.settings.image_2 | img_url: 'master' }} {{ block.settings.image_2.width }}w"
                                        data-src="{{ block.settings.image_2 | img_url: '1500x' }}"
                                        sizes="(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 2 }}px, (min-width: 750px) calc((100vw - 130px) / 2), calc((100vw - 50px) / 2)"
                                        alt="{{ block.settings.image_2.alt | escape }}"
                                        loading="lazy"
                                        class="lazyload"
                                        width="{{ block.settings.image_2.width }}"
                                        height="{{ block.settings.image_2.height }}"
                                      >
                                    {%- else -%}
                                      {{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
                                    {%- endif -%}
                                  </div>
                                  <div class="pop_content">
                                    <div class="pop_text">{{ block.settings.text_2 }}</div>
                                    <div>{{ block.settings.richtext_2 }}</div>
                                  </div>
                                </div>
                                <button id="ModalClose-{{ block.id }}-text_2" type="button" class="product-popup-modal__toggle" aria-label="{{ 'accessibility.close' | t }}">{% render 'pop-close' %}</button>
                              </div>
                           </modal-dialog> 
                           </div>
                      {% endif %}
                      {% if block.settings.text_3 != blank %}
                        <div class="text text_3"> 
                          <modal-opener class="twy-button product-popup-modal__opener no-js-hidden" data-modal="#PopupModal-{{ block.id }}-text_3" >
                            <button id="ProductPopup-{{ block.id }}-text_3" class="product-popup-modal__button link" type="button" aria-haspopup="dialog">
                              <span class="text-h1">{{ block.settings.text_3 }}</span>  {% render 'icon-jia' %}
                            </button>
                          </modal-opener>
                          <modal-dialog id="PopupModal-{{ block.id }}-text_3" class="product-popup-modal">
                            <div role="dialog" aria-label="{{  block.settings.text_3 }}" aria-modal="true" class="product-popup-modal__content" >
                              <div class="modal-popop">
                                <div class="image-with-text__media image-with-text__media--{{ block.settings.height }} {% if block.settings.image_3 != blank %}media{% else %}image-with-text__media--placeholder placeholder{% endif %}"
                                  {% if block.settings.image_3 != blank %} style="padding-bottom: {{ 1 | divided_by: block.settings.image_3.aspect_ratio | times: 100 }}%;"{% endif %}>
                                  {%- if block.settings.image_3 != blank -%}
                                    <img
                                      srcset="{%- if block.settings.image_3.width >= 165 -%}{{ block.settings.image_3 | img_url: '165x' }} 165w,{%- endif -%}
                                        {%- if block.settings.image_3.width >= 323 -%}{{ block.settings.image_3 | img_url: '323x' }} 323w,{%- endif -%}
                                        {%- if block.settings.image_3.width >= 360 -%}{{ block.settings.image_3 | img_url: '360x' }} 360w,{%- endif -%}
                                        {%- if block.settings.image_3.width >= 535 -%}{{ block.settings.image_3 | img_url: '535x' }} 535w,{%- endif -%}
                                        {%- if block.settings.image_3.width >= 750 -%}{{ block.settings.image_3 | img_url: '750x' }} 750w,{%- endif -%}
                                        {%- if block.settings.image_3.width >= 1070 -%}{{ block.settings.image_3 | img_url: '1070x' }} 1070w,{%- endif -%}
                                        {%- if block.settings.image_3.width >= 1500 -%}{{ block.settings.image_3 | img_url: '1500x' }} 1500w,{%- endif -%}
                                        {{ block.settings.image_3 | img_url: 'master' }} {{ block.settings.image_3.width }}w"
                                      data-src="{{ block.settings.image_3 | img_url: '1500x' }}"
                                      sizes="(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 2 }}px, (min-width: 750px) calc((100vw - 130px) / 2), calc((100vw - 50px) / 2)"
                                      alt="{{ block.settings.image_3.alt | escape }}"
                                      loading="lazy"
                                      class="lazyload"
                                      width="{{ block.settings.image_3.width }}"
                                      height="{{ block.settings.image_3.height }}"
                                    >
                                  {%- else -%}
                                    {{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
                                  {%- endif -%}
                                </div>
                                <div class="pop_content">
                                  <div class="pop_text">{{ block.settings.text_3 }}</div>
                                  <div>{{ block.settings.richtext_3 }}</div>
                                </div>
                               </div>
                              <button id="ModalClose-{{ block.id }}-text_3" type="button" class="product-popup-modal__toggle" aria-label="{{ 'accessibility.close' | t }}">{% render 'pop-close' %}</button>
                            </div>
                         </modal-dialog> 
                         </div>
                      {% endif %}
                      {% if block.settings.text_4 != blank %}
                        <div class="text text_4"> 
                          <modal-opener class="twy-button product-popup-modal__opener no-js-hidden" data-modal="#PopupModal-{{ block.id }}-text_4" >
                            <button id="ProductPopup-{{ block.id }}-text_4" class="product-popup-modal__button link" type="button" aria-haspopup="dialog">
                              <span class="text-h1">{{ block.settings.text_4 }}</span>  {% render 'icon-jia' %}
                            </button>
                          </modal-opener>
                          <modal-dialog id="PopupModal-{{ block.id }}-text_4" class="product-popup-modal">
                            <div role="dialog" aria-label="{{  block.settings.text_4 }}" aria-modal="true" class="product-popup-modal__content" >
                              <div class="modal-popop">
                                <div class="image-with-text__media image-with-text__media--{{ block.settings.height }} {% if block.settings.image_4 != blank %}media{% else %}image-with-text__media--placeholder placeholder{% endif %}"
                                  {% if block.settings.image_4 != blank %} style="padding-bottom: {{ 1 | divided_by: block.settings.image_4.aspect_ratio | times: 100 }}%;"{% endif %}>
                                  {%- if block.settings.image_4 != blank -%}
                                    <img
                                      srcset="{%- if block.settings.image_4.width >= 165 -%}{{ block.settings.image_4 | img_url: '165x' }} 165w,{%- endif -%}
                                        {%- if block.settings.image_4.width >= 323 -%}{{ block.settings.image_4 | img_url: '323x' }} 323w,{%- endif -%}
                                        {%- if block.settings.image_4.width >= 360 -%}{{ block.settings.image_4 | img_url: '360x' }} 360w,{%- endif -%}
                                        {%- if block.settings.image_4.width >= 535 -%}{{ block.settings.image_4 | img_url: '535x' }} 535w,{%- endif -%}
                                        {%- if block.settings.image_4.width >= 750 -%}{{ block.settings.image_4 | img_url: '750x' }} 750w,{%- endif -%}
                                        {%- if block.settings.image_4.width >= 1070 -%}{{ block.settings.image_4 | img_url: '1070x' }} 1070w,{%- endif -%}
                                        {%- if block.settings.image_4.width >= 1500 -%}{{ block.settings.image_4 | img_url: '1500x' }} 1500w,{%- endif -%}
                                        {{ block.settings.image_4 | img_url: 'master' }} {{ block.settings.image_4.width }}w"
                                      data-src="{{ block.settings.image_4 | img_url: '1500x' }}"
                                      sizes="(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 2 }}px, (min-width: 750px) calc((100vw - 130px) / 2), calc((100vw - 50px) / 2)"
                                      alt="{{ block.settings.image_4.alt | escape }}"
                                      loading="lazy"
                                      class="lazyload"
                                      width="{{ block.settings.image_4.width }}"
                                      height="{{ block.settings.image_4.height }}"
                                    >
                                  {%- else -%}
                                    {{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
                                  {%- endif -%}
                                </div>
                                <div class="pop_content">
                                  <div class="pop_text">{{ block.settings.text_4 }}</div>
                                  <div>{{ block.settings.richtext_4 }}</div>
                                </div>
                               </div>
                              <button id="ModalClose-{{ block.id }}-text_4" type="button" class="product-popup-modal__toggle" aria-label="{{ 'accessibility.close' | t }}">{% render 'pop-close' %}</button>
                            </div>
                         </modal-dialog> 
                         </div>
                      {% endif %}
                    {% if block.settings.text_5 != blank %}
                        <div class="text text_5"> 
                          <modal-opener class="twy-button product-popup-modal__opener no-js-hidden" data-modal="#PopupModal-{{ block.id }}-text_5" >
                            <button id="ProductPopup-{{ block.id }}-text_5" class="product-popup-modal__button link" type="button" aria-haspopup="dialog">
                              <span class="text-h1">{{ block.settings.text_5 }}</span>  {% render 'icon-jia' %}
                            </button>
                          </modal-opener>
                          <modal-dialog id="PopupModal-{{ block.id }}-text_5" class="product-popup-modal">
                            <div role="dialog" aria-label="{{  block.settings.text_5 }}" aria-modal="true" class="product-popup-modal__content" >
                              <div class="modal-popop">
                                <div class="image-with-text__media image-with-text__media--{{ block.settings.height }} {% if block.settings.image_5 != blank %}media{% else %}image-with-text__media--placeholder placeholder{% endif %}"
                                  {% if block.settings.image_5 != blank %} style="padding-bottom: {{ 1 | divided_by: block.settings.image_5.aspect_ratio | times: 100 }}%;"{% endif %}>
                                  {%- if block.settings.image_5 != blank -%}
                                    <img
                                      srcset="{%- if block.settings.image_5.width >= 165 -%}{{ block.settings.image_5 | img_url: '165x' }} 165w,{%- endif -%}
                                        {%- if block.settings.image_5.width >= 323 -%}{{ block.settings.image_5 | img_url: '323x' }} 323w,{%- endif -%}
                                        {%- if block.settings.image_5.width >= 360 -%}{{ block.settings.image_5 | img_url: '360x' }} 360w,{%- endif -%}
                                        {%- if block.settings.image_5.width >= 535 -%}{{ block.settings.image_5 | img_url: '535x' }} 535w,{%- endif -%}
                                        {%- if block.settings.image_5.width >= 750 -%}{{ block.settings.image_5 | img_url: '750x' }} 750w,{%- endif -%}
                                        {%- if block.settings.image_5.width >= 1070 -%}{{ block.settings.image_5 | img_url: '1070x' }} 1070w,{%- endif -%}
                                        {%- if block.settings.image_5.width >= 1500 -%}{{ block.settings.image_5 | img_url: '1500x' }} 1500w,{%- endif -%}
                                        {{ block.settings.image_5 | img_url: 'master' }} {{ block.settings.image_5.width }}w"
                                      data-src="{{ block.settings.image_5 | img_url: '1500x' }}"
                                      sizes="(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | divided_by: 2 }}px, (min-width: 750px) calc((100vw - 130px) / 2), calc((100vw - 50px) / 2)"
                                      alt="{{ block.settings.image_5.alt | escape }}"
                                      loading="lazy"
                                      class="lazyload"
                                      width="{{ block.settings.image_5.width }}"
                                      height="{{ block.settings.image_5.height }}"
                                    >
                                  {%- else -%}
                                    {{ 'image' | placeholder_svg_tag: 'placeholder-svg' }}
                                  {%- endif -%}
                                </div>
                                <div class="pop_content">
                                  <div class="pop_text">{{ block.settings.text_5 }}</div>
                                  <div>{{ block.settings.richtext_5 }}</div>
                                </div>
                               </div>
                              <button id="ModalClose-{{ block.id }}-text_5" type="button" class="product-popup-modal__toggle" aria-label="{{ 'accessibility.close' | t }}">{% render 'pop-close' %}</button>
                            </div>
                         </modal-dialog> 
                         </div>
                      {% endif %}
                    </div>
            {%- endcase -%}
          {%- endfor -%}     
        </div>
    </tab-toggle>     
  </div>
</div>

<script>
 $(window).ready(function() {
    var oTab = document.querySelector('.tab-block');
    var aTabNav = oTab.querySelectorAll('.ksp-tab .tab');
      var aTabContent = oTab.querySelectorAll('.point-feature .content');
     for(var i = 0; i < aTabNav.length; i++){
         aTabNav[i].onclick = (function (i) {
             return function () {
                 addCurClass(aTabNav,i);
                 addCurClass(aTabContent,i);
             }
         })(i);
     }
   });
 
   function addCurClass(obj,index) {
     for(var i = 0; i < obj.length; i++){
         obj[i].classList.remove('cur');
     }
     obj[index].classList.add('cur');
   }
</script>


{% schema %}
    {
      "name": "Ksp collection",
      "tag": "section",
      "class": "spaced-section ksp-collection spaced-section--full-width",
      "settings": [
        {
          "type": "text",
          "id": "heading",
          "label": "Heading"
        },
        {
          "type": "richtext",
          "id": "richtext",
          "label": "Richtext"
        },
        {
            "type": "image_picker",
            "id": "image",
            "label": "Image"
        },
        {
            "type": "select",
            "id": "height",
            "options": [
              {
                "value": "adapt",
                "label": "adapt"
              },
              {
                "value": "small",
                "label": "small"
              },
              {
                "value": "large",
                "label": "large"
              }
          ],
          "default": "adapt",
          "label": "adapt"
        }
      ],
      "blocks": [
      {
        "type": "tab",
        "name": "tab",
        "settings": [
          {
            "type": "text",
            "id": "text",
            "label": "text"
          }
        ]
      },
      {
        "type": "point",
        "name": "point",
        "settings": [
          {
            "type": "text",
            "id": "text_1",
            "label": "text 1"
          },
          {
            "type": "image_picker",
            "id": "image",
            "label": "Image"
          },
          {
            "type": "richtext",
            "id": "richtext",
            "label": "richtext"
          },
          {
            "type": "text",
            "id": "text_2",
            "label": "text 2"
          },
          {
            "type": "image_picker",
            "id": "image_2",
            "label": "Image 2"
          },
          {
            "type": "richtext",
            "id": "richtext_2",
            "label": "richtext 2"
          },
          {
            "type": "text",
            "id": "text_3",
            "label": "text 3"
          },
          {
            "type": "image_picker",
            "id": "image_3",
            "label": "Image 3"
          },
          {
            "type": "richtext",
            "id": "richtext_3",
            "label": "richtext 3"
          },
          {
            "type": "text",
            "id": "text_4",
            "label": "text 4"
          },
          {
            "type": "image_picker",
            "id": "image_4",
            "label": "Image 4"
          },
          {
            "type": "richtext",
            "id": "richtext_4",
            "label": "richtext 4"
          },
          {
            "type": "text",
            "id": "text_5",
            "label": "text 5"
          },
          {
            "type": "image_picker",
            "id": "image_5",
            "label": "Image 5"
          },
          {
            "type": "richtext",
            "id": "richtext_5",
            "label": "richtext 5"
          }
        ]
      }
    ],
      "presets": [
        {
          "name": "Ksp collection"
        }
      ]
    }
      {% endschema %}